<?php

namespace App\Http\Middleware;

use App\User;
use Closure;

class check_token
{
    /**
     * Handle an incoming request.
     *
     * @param  \Illuminate\Http\Request  $request
     * @param  \Closure  $next
     * @return mixed
     */
    public function handle($request, Closure $next)
    {
        $api_token = $request->input('api_token');
        $user = User::where('api_token',$api_token)->first();
        if(!$user){
            return response()->json(['data'=>'权限不足'],201);
        }
        return $next($request);
    }
}
